# In Windows, you can drag and drop this configuration file to the, "scaswr.bat",
# batch file to configure Soarer's converter.  The name of this
# text file can end in *.txt or *.sc or anything else.  The *.txt extension
# might be more convenient in the Windows operating system so that you can 
# double click on the file name to edit the file in the Notepad program.

# Soarer configuration files are case-insensitive.
# You can use tab or space characters to align text.
# Text to the right of # characters are comments.

# April 29, 2020

# If you actually have a PC/XT keyboard, then remove 
# or comment out the following 2 lines:
ifkeyboard 0000
force set2ext

# My Rosewill RK-9000V2 keyboard can use either a PS/2 cable or a USB cable
# and returns a keyboard ID of 0000 (zero) with the PS/2 cable attached to
# Soarer's converter.  Soarer's converter incorrectly assumes the RK-9000V2
# keyboard is a PC/XT keyboard.

# set1 is the PC/XT keyboard scan code set.
# set2 is the AT keyboard scan code set.
# set2ext is the PS/2 keyboard scan code set.
# set3 is the 3179/318x/319x terminal keyboard scan code set.


ifkeyboard any
ifselect any

layerblock
  FN1 1  # FN1 is a virtual key for entering keyboard layer 1 and is not the same thing as a physical F1 function key.
endblock

# Enter your default key mappings here:

remapblock
	RALT		RGUI	# The Right Alt key becomes the Right Windows key
	CAPS_LOCK	FN1	# The CAPS_LOCK key becomes like a shift key to enter keyboard layer 1
endblock

# The following are key remaps for keyboard layer 1 which is accessed by holding down the CAPS_LOCK key.
remapblock
 layer 1
	C		PAGE_DOWN	# CAPS_LOCK C is like the WordStar text editor command to page down
	R		PAGE_UP		# CAPS_LOCK R is like the WordStar text editor command to page up

	E		UP		# CAPS_LOCK E is UP arrow
	X		DOWN		# CAPS_LOCK X is DOWN arrow
	S		LEFT		# CAPS_LOCK S is LEFT arrow
	D		RIGHT		# CAPS_LOCK D is RIGHT arrow

	F		AUX1		# AUX1 is an unused key for triggering a macro to press CTRL RIGHT to move one word to the right
	A		AUX2		# AUX2 is an unused key for triggering a macro to press CTRL LEFT to move one word to the left

	I		AUX3		# AUX3 is an unused key for triggering a macro to press "It was nice doing business with you."

	0		AUX4		# AUX4 is an unused key for triggering a macro to press "0P0100" when CAPS_LOCK 0 (zero) is pressed

	G		DELETE		# CAPS_LOCK G is like the WordStar command to delete a character
	H		BACKSPACE	# CAPS_LOCK H is like the WordStar command to backspace

	QUOTE		AUX5
endblock

# Enter your default macro definitions here:

macroblock
  # The macros with the longest number of modifiers like LCTRL LALT LSHIFT LGUI
  # should be defined first so that macros with a fewer number of modifiers
  # do not get executed first.

  # The gray number pad keys on my keyboard have no special meaning with 
  # modifiers, so any combination of modifiers like LCTRL, LALT, LSHIFT. 
  # LGUI, RCTRL, RALT, RSHIFT, RGUI can be used with the number pad keys
  # for macros:
  #
  #   NUM_LOCK 
  #   PAD_SLASH 
  #   PAD_ASTERIX
  #   PAD_MINUS
  #   PAD_PLUS
  #   PAD_ENTER

  # The modifier keys LSHIFT, RSHIFT, LCTRL, RCTRL, LALT, RALT, LGUI, RGUI
  # are declared to the right of the key that is modified.  The L prefix
  # means Left.  The R prefix means Right.
  # -ctrl means exclude both LCTRL and RCTRL
  # -alt means exclude both LALT and RALT
  # -gui means exclude both LGUI (Left Window key) and RGUI (Right Window key)

  # Pressing LEFT SHIFT with NUM LOCK activates the Colemak keyboard layout.
  macro NUM_LOCK LSHIFT -ctrl -alt -gui
    push_meta clear_meta all
    press SELECT_0  # Clear any previous keyboard layout selection
    press SELECT_1  # Activate the SELECT_1 keyboard layout, Colemak
    pop_all_meta
  endmacro

  # Pressing LEFT CTRL with NUM LOCK activates the Dvorak keyboard layout.
  macro NUM_LOCK LCTRL -shift -alt -gui
    push_meta clear_meta all
    press SELECT_0  # Clear any previous keyboard layout selection
    press SELECT_2  # Activate the SELECT_2 keyboard layout, Dvorak
    pop_all_meta
  endmacro

  # Pressing LEFT ALT with NUM LOCK resets all keyboard layout selections
  # and returns to the default keyboard layout.
  macro NUM_LOCK LALT -ctrl -shift -gui
    push_meta clear_meta all
    press SELECT_0  # Clear any previous keyboard layout selection
    pop_all_meta
  endmacro

  # Pressing SCROLL_LOCK by itself toggles the case of letters with the space
  # character replaced by an underline character, SUCH_AS_THIS.  This works 
  # with the Colemak, Dvorak, or default keyboard layouts.  This assumes
  # that the CAPS_LOCK is not already on.  If CAPS_LOCK is on, then when
  # you toggle on SELECT_3, the letters will be in lower case and the space
  # character will be an underline, such_as_this.  If you press the Right Shift
  # key while in the SELECT_3 configuration, then the shift will be toggled off,
  # resulting in text such-as-this.  In this situation, press SCROLL_LOCK again
  # to turn the MINUS back into a SPACE and press the Right Shift key to release
  # the shift toggle.

  macro SCROLL_LOCK -shift -ctrl -alt -gui
    toggle_meta RSHIFT
    press SELECT_3
  endmacro

  # Make NUM_LOCK do nothing or use it for something else.
  # The NUM_LOCK key sometimes causes the RK-9000V2 keyboard to lock up.
  macro NUM_LOCK -alt -ctrl -shift -gui
  endmacro

  # Simultaneously pressing Left Shift and Right Shift will have the same
  # effect as pressing CAPS_LOCK.  This frees up the Caps Lock key to be
  # something more useful, such as the left Ctrl key (LCTRL) or as a
  # shift into keyboard layer 1. There are 2 entries here for pressing
  # either the right shift key first and then the left shift key or
  # pressing the left key first and then the right shift key.
  #
  # On the RK-9000V2 keyboard, you have to wait about a second before
  # resuming typing or the keyboard will lock up.  The LED lights for
  # CAPS_LOCK, NuM_LOCK, and SCROLL_LOCK all flash in unison when any
  # one of these keys is pressed with Soarer'r converter attached and
  # do not properly indicate the lock state of any of these keys.

  macro LSHIFT RSHIFT -ctrl -alt -gui
    clear_meta shift
    press CAPS_LOCK
  endmacro

  macro RSHIFT LSHIFT -ctrl -alt -gui
    clear_meta shift
    press CAPS_LOCK
  endmacro

  # CAPS_LOCK F presses LCTRL RIGHT arrow to move forward one word
  macro AUX1
    push_meta clear_meta all
    set_meta LCTRL
    press RIGHT
    pop_all_meta
  endmacro

  # CAPS_LOCK A presses LCTRL LEFT arrow to move back one word
  macro AUX2
    push_meta clear_meta all
    set_meta LCTRL
    press LEFT
    pop_all_meta
  endmacro

  # CAPS_LOCK I outputs a message, "It was nice doing business with you."
  macro AUX3
    push_meta clear_meta all
    set_meta LSHIFT
    press i
    clear_meta LSHIFT
    press t
    press SPACE
    press w
    press a
    press s
    press SPACE
    press n
    press i
    press c
    press e
    press SPACE
    press d
    press o
    press i
    press n
    press g
    press SPACE
    press b
    press u
    press s
    press i
    press n
    press e
    press s
    press s
    press SPACE
    press w
    press i
    press t
    press h
    press SPACE
    press y
    press o
    press u
    press PERIOD
    pop_all_meta
  endmacro

  # CAPS_LOCK 0 outputs, "0P0100", followed by a TAB
  macro AUX4
    push_meta clear_meta all
    press 0
    set_meta LSHIFT
    press p
    clear_meta LSHIFT
    press 0
    press 1
    press 0
    press 0
    press TAB
    pop_all_meta
  endmacro

  # CAPS_LOCK QUOTE macro to comment a line in Visual Basic
  macro AUX5
    push_meta clear_meta all
    press HOME
    press QUOTE
    press DOWN
    pop_all_meta
  endmacro

endblock

# The contents of the sample, "colemak.sc", and, "dvorak.sc", files are
# included here for easy adjustment.

ifselect 1

# Colemak keyboard layout.
# Holding down the LEFT SHIFT key and then pressing the NUM LOCK key
# activates the Select 1 state and the Colemak keyboard layout
# which stays active until you switch to another keyboard layout.

remapblock
	D S
	E F
	F T
	G D
	I U
	J N
	K E
	L I
	N K
	O Y
	P SEMICOLON
	R P
	S R
	T G
	U L
	Y J
	SEMICOLON O
endblock


ifselect 2

# Dvorak keyboard layout - contributed by Morning Song.
# Holding down the LEFT CTRL key and then pressing the NUM LOCK key
# activates the Select 2 state and the Dvorak keyboard layout
# which stays active until you switch to another keyboard layout.

remapblock
	MINUS		LEFT_BRACE
	EQUAL		RIGHT_BRACE
	Q		QUOTE
	W		COMMA
	E		PERIOD
	R		P
	T		Y
	Y		F
	U		G
	I		C
	O		R
	P		L
	LEFT_BRACE	SLASH
	RIGHT_BRACE	EQUAL
#	A		A
	S		O
	D		E
	F		U
	G		I
	H		D
	J		H
	K		T
	L		N
	SEMICOLON	S
	QUOTE		MINUS	
	Z		SEMICOLON
	X		Q
	C		J
	V		K
	B		X
	N		B
#	M		M
	COMMA		W
	PERIOD		V
	SLASH		Z		
endblock


ifselect 3

remapblock
	SPACE		MINUS
endblock

#
# Modified HID Code set Reference
#
#
# If you run the:
#
#   hid_listen.exe
#
# program and press a key, look for a + sign followed by a
# hexadecimal number in the output to identify the key you pressed.
#
# The codes on the left side of the following list are what you use
# to remap keys.  The text on the right side are Soarer's comments.

# UNASSIGNED		+00	No Event
# OVERRUN_ERROR		+01	Overrun Error
# POST_FAIL		+02	POST Fail
# ERROR_UNDEFINED	+03	ErrorUndefined
# A			+04	a A
# B			+05	b B
# C			+06	c C
# D			+07	d D
# E			+08	e E
# F			+09	f F
# G			+0A	g G
# H			+0B	h H
# I			+0C	i I
# J			+0D	j J
# K			+0E	k K
# L			+0F	l L
# M			+10	m M
# N			+11	n N
# O			+12	o O
# P			+13	p P
# Q			+14	q Q
# R			+15	r R
# S			+16	s S
# T			+17	t T
# U			+18	u U
# V			+19	v V
# W			+1A	w W
# X			+1B	x X
# Y			+1C	y Y
# Z			+1D	z Z
# 1			+1E	1 !
# 2			+1F	2 @
# 3			+20	3 #
# 4			+21	4 $
# 5			+22	5 %
# 6			+23	6 ^
# 7			+24	7 &
# 8			+25	8 *
# 9			+26	9 (
# 0			+27	0 )
# ENTER			+28	Return
# ESC			+29	Escape
# BACKSPACE		+2A	Backspace
# TAB			+2B	Tab
# SPACE			+2C	Space
# MINUS			+2D	- _
# EQUAL			+2E	= +
# LEFT_BRACE		+2F	[ {
# RIGHT_BRACE		+30	] }
# BACKSLASH		+31	\ |
# EUROPE_1		+32	Europe 1 (use BACKSLASH instead)
# SEMICOLON		+33	; :
# QUOTE			+34	' "
# BACK_QUOTE		+35	` ~
# COMMA			+36	, <
# PERIOD		+37	. >
# SLASH			+38	/ ?
# CAPS_LOCK		+39	Caps Lock
# F1			+3A	F1
# F2			+3B	F2
# F3			+3C	F3
# F4			+3D	F4
# F5			+3E	F5
# F6			+3F	F6
# F7			+40	F7
# F8			+41	F8
# F9			+42	F9
# F10			+43	F10
# F11			+44	F11
# F12			+45	F12
# PRINTSCREEN		+46	Print Screen
# SCROLL_LOCK		+47	Scroll Lock
# PAUSE			+48	Pause
# INSERT		+49	Insert
# HOME			+4A	Home
# PAGE_UP		+4B	Page Up
# DELETE		+4C	Delete
# END			+4D	End
# PAGE_DOWN		+4E	Page Down
# RIGHT			+4F	Right Arrow
# LEFT			+50	Left Arrow
# DOWN			+51	Down Arrow
# UP			+52	Up Arrow
# NUM_LOCK		+53	Num Lock
# PAD_SLASH		+54	Keypad /
# PAD_ASTERIX		+55	Keypad *
# PAD_MINUS		+56	Keypad -
# PAD_PLUS		+57	Keypad +
# PAD_ENTER		+58	Keypad Enter
# PAD_1			+59	Keypad 1 End
# PAD_2			+5A	Keypad 2 Down
# PAD_3			+5B	Keypad 3 PageDn
# PAD_4			+5C	Keypad 4 Left
# PAD_5			+5D	Keypad 5
# PAD_6			+5E	Keypad 6 Right
# PAD_7			+5F	Keypad 7 Home
# PAD_8			+60	Keypad 8 Up
# PAD_9			+61	Keypad 9 PageUp
# PAD_0			+62	Keypad 0 Insert
# PAD_PERIOD		+63	Keypad . Delete
# EUROPE_2		+64	Europe 2
# APP			+65	App (Windows Menu)
# POWER			+66	Keyboard Power
# PAD_EQUALS		+67	Keypad =
# F13			+68	F13
# F14			+69	F14
# F15			+6A	F15
# F16			+6B	F16
# F17			+6C	F17
# F18			+6D	F18
# F19			+6E	F19
# F20			+6F	F20
# F21			+70	F21
# F22			+71	F22
# F23			+72	F23
# F24			+73	F24
# EXECUTE		+74	Keyboard Execute
# HELP			+75	Keyboard Help
# MENU			+76	Keyboard Menu
# SELECT		+77	Keyboard Select
# STOP			+78	Keyboard Stop
# AGAIN			+79	Keyboard Again
# UNDO			+7A	Keyboard Undo
# CUT			+7B	Keyboard Cut
# COPY			+7C	Keyboard Copy
# PASTE			+7D	Keyboard Paste
# FIND			+7E	Keyboard Find
# MUTE			+7F	Keyboard Mute
# VOLUME_UP		+80	Keyboard Volume Up
# VOLUME_DOWN		+81	Keyboard Volume Dn
# LOCKING_CAPS_LOCK	+82	Keyboard Locking Caps Lock
# LOCKING_NUM_LOCK	+83	Keyboard Locking Num Lock
# LOCKING_SCROLL_LOCK	+84	Keyboard Locking Scroll Lock
# PAD_COMMA		+85	Keypad comma (Brazilian Keypad .)
# EQUAL_SIGN		+86	Keyboard Equal Sign
# INTERNATIONAL_1	+87	Keyboard Int'l 1 (Ro)
# INTERNATIONAL_2	+88	Keyboard Intl'2 (Katakana/Hiragana)
# INTERNATIONAL_3	+89	Keyboard Int'l 2 (Yen)
# INTERNATIONAL_4	+8A	Keyboard Int'l 4 (Henkan)
# INTERNATIONAL_5	+8B	Keyboard Int'l 5 (Muhenkan)
# INTERNATIONAL_6	+8C	Keyboard Int'l 6 (PC9800 Keypad comma)
# INTERNATIONAL_7	+8D	Keyboard Int'l 7
# INTERNATIONAL_8	+8E	Keyboard Int'l 8
# INTERNATIONAL_9	+8F	Keyboard Int'l 9
# LANG_1		+90	Keyboard Lang 1 (Hanguel/English)
# LANG_2		+91	Keyboard Lang 2 (Hanja)
# LANG_3		+92	Keyboard Lang 3 (Katakana)
# LANG_4		+93	Keyboard Lang 4 (Hiragana)
# LANG_5		+94	Keyboard Lang 5 (Zenkaku/Hankaku)
# LANG_6		+95	Keyboard Lang 6
# LANG_7		+96	Keyboard Lang 7
# LANG_8		+97	Keyboard Lang 8
# LANG_9		+98	Keyboard Lang 9
# ALTERNATE_ERASE	+99	Keyboard Alternate Erase
# SYSREQ_ATTN		+9A	Keyboard SysReq/Attention
# CANCEL		+9B	Keyboard Cancel
# CLEAR			+9C	Keyboard Clear (use DELETE instead)
# PRIOR			+9D	Keyboard Prior
# RETURN		+9E	Keyboard Return
# SEPARATOR		+9F	Keyboard Separator
# OUT			+A0	Keyboard Out
# OPER			+A1	Keyboard Oper
# CLEAR_AGAIN		+A2	Keyboard Clear/Again
# CRSEL_PROPS		+A3	Keyboard CrSel/Props
# EXSEL			+A4	Keyboard ExSel
# SYSTEM_POWER		+A8	System Power
# SYSTEM_SLEEP		+A9	System Sleep
# SYSTEM_WAKE		+AA	System Wake
# AUX1			+AB	Auxiliary key 1
# AUX2			+AC	Auxiliary key 2
# AUX3			+AD	Auxiliary key 3
# AUX4			+AE	Auxiliary key 4
# AUX5			+AF	Auxiliary key 5
# FAKE_01		+B0	extra
# EXTRA_LALT		+B1	AT-F extra pad lhs of space
# EXTRA_PAD_PLUS	+B2	Term extra pad bottom of keypad +
# EXTRA_RALT		+B3	AT-F extra pad rhs of space
# EXTRA_EUROPE_2	+B4	AT-F extra pad lhs of enter
# EXTRA_BACKSLASH	+B5	AT-F extra pad top of enter
# EXTRA_INSERT		+B6	AT-F extra pad lhs of Insert
# EXTRA_F1		+B7	122-key Terminal lhs F1
# EXTRA_F2		+B8	122-key Terminal lhs F2
# EXTRA_F3		+B9	122-key Terminal lhs F3
# EXTRA_F4		+BA	122-key Terminal lhs F4
# EXTRA_F5		+BB	122-key Terminal lhs F5
# EXTRA_F6		+BC	122-key Terminal lhs F6
# EXTRA_F7		+BD	122-key Terminal lhs F7
# EXTRA_F8		+BE	122-key Terminal lhs F8
# EXTRA_F9		+BF	122-key Terminal lhs F9
# EXTRA_F10		+C0	122-key Terminal lhs F10
# FAKE_18		+C1	extra
# EXTRA_SYSRQ		+C2	Sys Req (AT 84-key)
# FN1			+D0	Function layer key 1
# FN2			+D1	Function layer key 2
# FN3			+D2	Function layer key 3
# FN4			+D3	Function layer key 4
# FN5			+D4	Function layer key 5
# FN6			+D5	Function layer key 6
# FN7			+D6	Function layer key 7
# FN8			+D7	Function layer key 8
# SELECT_0		+D8	Select reset
# SELECT_1		+D9	Select 1 toggle
# SELECT_2		+DA	Select 2 toggle
# SELECT_3		+DB	Select 3 toggle
# SELECT_4		+DC	Select 4 toggle
# SELECT_5		+DD	Select 5 toggle
# SELECT_6		+DE	Select 6 toggle
# SELECT_7		+DF	Select 7 toggle
# LCTRL			+E0	Left Control
# LSHIFT		+E1	Left Shift
# LALT			+E2	Left Alt
# LGUI			+E3	Left GUI (Left Windows)
# RCTRL			+E4	Right Control
# RSHIFT		+E5	Right Shift
# RALT			+E6	Right Alt
# RGUI			+E7	Right GUI (Right Windows)
# MEDIA_NEXT_TRACK	+E8	Scan Next Track
# MEDIA_PREV_TRACK	+E9	Scan Previous Track
# MEDIA_STOP		+EA	Stop
# MEDIA_PLAY_PAUSE	+EB	Play/ Pause
# MEDIA_MUTE		+EC	Mute
# MEDIA_BASS_BOOST	+ED	Bass Boost
# MEDIA_LOUDNESS	+EE	Loudness
# MEDIA_VOLUME_UP	+EF	Volume Up
# MEDIA_VOLUME_DOWN	+F0	Volume Down
# MEDIA_BASS_UP		+F1	Bass Up
# MEDIA_BASS_DOWN	+F2	Bass Down
# MEDIA_TREBLE_UP	+F3	Treble Up
# MEDIA_TREBLE_DOWN	+F4	Treble Down
# MEDIA_MEDIA_SELECT	+F5	Media Select
# MEDIA_MAIL		+F6	Mail
# MEDIA_CALCULATOR	+F7	Calculator
# MEDIA_MY_COMPUTER	+F8	My Computer
# MEDIA_WWW_SEARCH	+F9	WWW Search
# MEDIA_WWW_HOME	+FA	WWW Home
# MEDIA_WWW_BACK	+FB	WWW Back
# MEDIA_WWW_FORWARD	+FC	WWW Forward
# MEDIA_WWW_STOP	+FD	WWW Stop
# MEDIA_WWW_REFRESH	+FE	WWW Refresh
# MEDIA_WWW_FAVORITES	+FF	WWW Favorites

# Deprecated Code Names

# FAKE_01		+B0	extra
# FAKE_02		+B1	AT-F extra pad lhs of space
# FAKE_03		+B2	Term extra pad bottom of keypad +
# FAKE_04		+B3	AT-F extra pad rhs of space
# FAKE_05		+B4	AT-F extra pad lhs of enter
# FAKE_06		+B5	AT-F extra pad top of enter
# FAKE_07		+B6	AT-F extra pad lhs of Insert
# FAKE_08		+B7	Term F1
# FAKE_09		+B8	Term F2
# FAKE_10		+B9	Term F3
# FAKE_11		+BA	Term F4
# FAKE_12		+BB	Term F5
# FAKE_13		+BC	Term F6
# FAKE_14		+BD	Term F7
# FAKE_15		+BE	Term F8
# FAKE_16		+BF	Term F9
# FAKE_17		+C0	Term F10
# FAKE_18		+C1	extra
# FAKE_19		+C2	Sys Req (AT 84-key)

# Modifiers

# LCTRL		Left Control
# LSHIFT	Left Shift
# LALT		Left Alt
# LGUI		Left GUI (Left Windows)
# RCTRL		Right Control
# RSHIFT	Right Shift
# RALT		Right Alt
# RGUI		Right GUI (Right Windows)
# CTRL		Either/Both Control (shorthand for LCTRL RCTRL)
# SHIFT		Either/Both Shift (shorthand for LSHIFT RSHIFT)
# ALT		Either/Both Alt (shorthand for LALT RALT)
# GUI		Either/Both GUI (shorthand for LGUI RGUI)
# ALL		Any/All (shorthand for CTRL SHIFT ALT GUI)
